<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="database.DAO,golf.OnItemList,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
	request.setCharacterEncoding("utf-8");
	DAO dao = DAO.getInstance();
	int charNo=0;
	if(session.getAttribute("charNo")!=null)
	{
		charNo= (Integer)session.getAttribute("charNo");
	}
	
	
	String target = request.getParameter("select");
	int t = Integer.parseInt(target);
	String[] info= request.getParameterValues("info");
	int guildno=0;
	if(session.getAttribute("guildNo")!=null)
	{
		guildno= (Integer)session.getAttribute("guildNo");
	}
	
	String id = (String)session.getAttribute("accountID");
	int serverNo = (Integer)session.getAttribute("serverNo");
	int flag=0;
	if(target!=null)
	{
		if(info!=null){
			
			if(t==1)
			{
				for(int i=0;i<info.length;i++)
				{
					StringTokenizer a = new StringTokenizer(info[i], "+");
					int j= Integer.parseInt(a.nextToken());
					int k= Integer.parseInt(a.nextToken());
					out.println(dao.wearItem( charNo,k,j,flag ));
				}
				System.out.println("착용했삽");
			}
			else if(t==2)
			{
				if(guildno==0)
				{
					out.println("길드에 가입되어있지 않습니다.");
				}
				else if(guildno>0){
					for(int i=0;i<info.length;i++)
					{
						StringTokenizer b = new StringTokenizer(info[i], "+");
						int j= Integer.parseInt(b.nextToken());
						int k= Integer.parseInt(b.nextToken());
						out.println(dao.transItem(guildno,"",j,2 ));
					}
					System.out.println("길드로 보냈삽");
				}
			}
			else if(t==3)
			{
				for(int i=0;i<info.length;i++)
				{
					StringTokenizer c = new StringTokenizer(info[i], "+");
					int j= Integer.parseInt(c.nextToken());
					int k= Integer.parseInt(c.nextToken());
					out.println(dao.transItem(serverNo,id,j,3 ));
				}
				System.out.println("락커룸으로 보냈삽");
			}
			else if(t==4)
			{
				for(int i=0;i<info.length;i++)
				{
					StringTokenizer d = new StringTokenizer(info[i], "+");
					int j= Integer.parseInt(d.nextToken());
					int k= Integer.parseInt(d.nextToken());
					out.println(dao.caddyItem(charNo,k,j,0));
				}
				System.out.println("캐디백으로 보냈삽");
			}
		}else
		{
			out.println("선택된 값이 없습니다.");
		}
	}
	else
	{
		System.out.println("타겟을 설정해 주세요");	
	}
	
	response.sendRedirect("../jsp/manageItem.jsp");
%>